package zhangxin;

import java.util.Random;

//ACDG
//ABEF
//DE

class MinAndMax {
    private double min;
    private double max;
    public static class GetMinAndMax {
        public static MinAndMax getResult(double[] arr) {
            if (arr == null || arr.length == 0) {
                throw new IllegalArgumentException("数组为空！");
            }
            double min = arr[0];
            double max = arr[0];
            for (double v : arr) {
                if (v < min) min = v;
                if (v > max) max = v;
            }
            MinAndMax result = new MinAndMax();
            result.min = min;
            result.max = max;
            return result;
        }
    }
    public double getMin() {
        return min;
    }

    public double getMax() {
        return max;
    }
}

public class TestStaticClass {
    public static void main(String[] args) {
        double[] arr = new double[10];
        Random rand = new Random();
        for (int i = 0; i < arr.length; i++) {
            arr[i] = 10 * rand.nextDouble();   // 0–10 之间
        }
        System.out.println("输出这10个数：");
        for (double v : arr) {
            System.out.println(v);
        }
        MinAndMax res = MinAndMax.GetMinAndMax.getResult(arr);
        System.out.println("最大值：" + res.getMax());
        System.out.println("最小值：" + res.getMin());
    }
}